package com.example.demo.Task;

import com.example.demo.domain.send.DingMessage;
import com.example.demo.service.CourseService;
import com.example.demo.service.SendDingMessageService;
import com.example.demo.utils.ParseUtil;
import java.util.Arrays;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author lizijian
 */
@Data
@Slf4j
public class GetTeacherCourseThread implements Runnable {

    private CourseService courseService;

    private String classRoom;


    public GetTeacherCourseThread(CourseService courseService, String classRoom) {
        this.courseService = courseService;
        this.classRoom = classRoom;
    }


    @Override
    public void run() {
        try {
            ParseUtil.getTeacherCourse(classRoom);
        } catch (Exception e){
            log.error(classRoom+"-getTeacherCourse error");
            log.error("errorMessage:"+e.getMessage());
            log.error("stack:"+ Arrays.toString(e.getStackTrace()));
            SendDingMessageService.sendGetDataMessage(new DingMessage("爬取"+classRoom+"教室老师课程信息失败,errorMessage:"+e.getMessage()));
        }
    }

}
